#include "forwrewwid.h"

forwrewWid::forwrewWid(QString icon)
{
        forwrewPix = new QPixmap(QString(QApplication::applicationDirPath() + "/themes" + icon));
        this->setPixmap(*forwrewPix);
}

void forwrewWid::mousePressEvent ( QGraphicsSceneMouseEvent * event )
{

        start = QTime::currentTime();
        if(event->pos().rx() < (this->boundingRect().width() / 2)){
                emit this->rewStarted();
                qDebug() << "Event => rewStarted()";
        }else{
                emit this->forwardStarted();
                qDebug() << "Event => forwardStarted()";
        }
}

void forwrewWid::mouseReleaseEvent ( QGraphicsSceneMouseEvent * event )
{

        stop = QTime::currentTime();
        if(event->pos().rx() < (this->boundingRect().width() / 2)){
                emit this->rewEnded(start.msecsTo(stop));
                qDebug() << "Event => rewEnded("<< start.msecsTo(stop) << ")";
        }else{
                emit this->forwardEnded(start.msecsTo(stop));
                qDebug() << "Event => forwardEnded("<< start.msecsTo(stop) << ")";
        }
}

